package com.tws.pctask.controller;

import com.tws.common.model.ResponseWrapper;
import com.tws.common.tool.CommonTool;
import com.tws.common.tool.DataProcessing;
import com.tws.pctask.model.storehouseManageModel.*;
import com.tws.pctask.service.StorehouseManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Description： 仓库管理控制层
 * @Author: wbf
 * @Date: 2022/3/15 12:43
 */
@RestController
@CrossOrigin
@RequestMapping("systemFunction/basicSetting/storehouseManage")
public class StorehouseManageController {
    @Autowired
    private StorehouseManageService storehouseManageService;
    /**
     * 5.1获取仓库列表
     * @param param 获取仓库列表参数 详情见该类注释
     * @return 仓库列表
     */
    @GetMapping("getStorehouseList")
    public ResponseWrapper getStorehouseList(@Validated GetStorehouseListParam param){
        return storehouseManageService.getStorehouseList(param);
    }
    /**
     * 5.2新增或修改仓库
     * @param param 新增或修改仓库列表参数 详情见该类注释
     * @return 操作结果
     */
    @PostMapping("addOrUpdateStorehouse")
    public ResponseWrapper addOrUpdateStorehouse(@Validated AddOrUpdateStorehouseParam param){
        return storehouseManageService.addOrUpdateStorehouse(param);
    }

    /**
     * 5.3检查仓库名称是否重复
     * @param param 仓库名称
     * @return 是否重复
     */
    @GetMapping("checkStorehouseName")
    public ResponseWrapper checkStorehouseName(CheckStorehouseNameParam param){
        return storehouseManageService.checkStorehouseName(param);
    }

    /**
     * 5.4获取单个仓库信息
     * @param param 仓库id
     * @return 仓库信息
     */
    @GetMapping("getStorehouseInfo")
    public ResponseWrapper getStorehouseInfo(@Validated GetStorehouseInfoParam param){
        return storehouseManageService.getStorehouseInfo(param);
    }

    /**
     * 5.5删除仓库
     * @param param 仓库id
     * @return 相应消息
     */
    @PostMapping("delStorehouse")
    public ResponseWrapper delStorehouse(@Validated DelStorehouseParam param){
        return storehouseManageService.delStorehouse(param);
    }
}
